using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class MaterialReqInfo
    {
		#region Local Variable
		public enum Field
		{
			DTB,
			RequestNo,
			RequestDate,
			ReqFrom,
			ReqTo,
			IssueTo,
			BudgetCode,
			GLAccount,
			ShippedBy,
			ApprovedBy,
			CreatedBy,
			CreatedDate,
			ModifiedBy,
			ModifiedDate
		}
		private String _DTB;
		private String _RequestNo;
		private DateTime _RequestDate;
		private String _ReqFrom;
		private String _ReqTo;
		private String _IssueTo;
		private String _BudgetCode;
		private String _GLAccount;
		private String _ShippedBy;
		private String _ApprovedBy;
		private String _CreatedBy;
		private DateTime _CreatedDate;
		private String _ModifiedBy;
		private DateTime _ModifiedDate;
		
		public String DTB{	get{ return _DTB;} set{_DTB = value;} }
		public String RequestNo{	get{ return _RequestNo;} set{_RequestNo = value;} }
		public DateTime RequestDate{	get{ return _RequestDate;} set{_RequestDate = value;} }
		public String ReqFrom{	get{ return _ReqFrom;} set{_ReqFrom = value;} }
		public String ReqTo{	get{ return _ReqTo;} set{_ReqTo = value;} }
		public String IssueTo{	get{ return _IssueTo;} set{_IssueTo = value;} }
		public String BudgetCode{	get{ return _BudgetCode;} set{_BudgetCode = value;} }
		public String GLAccount{	get{ return _GLAccount;} set{_GLAccount = value;} }
		public String ShippedBy{	get{ return _ShippedBy;} set{_ShippedBy = value;} }
		public String ApprovedBy{	get{ return _ApprovedBy;} set{_ApprovedBy = value;} }
		public String CreatedBy{	get{ return _CreatedBy;} set{_CreatedBy = value;} }
		public DateTime CreatedDate{	get{ return _CreatedDate;} set{_CreatedDate = value;} }
		public String ModifiedBy{	get{ return _ModifiedBy;} set{_ModifiedBy = value;} }
		public DateTime ModifiedDate{	get{ return _ModifiedDate;} set{_ModifiedDate = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public MaterialReqInfo()
		{
			_DTB = "";
			_RequestNo = "";
			_RequestDate = DateTime.Now;
			_ReqFrom = "";
			_ReqTo = "";
			_IssueTo = "";
			_BudgetCode = "";
			_GLAccount = "";
			_ShippedBy = "";
			_ApprovedBy = "";
			_CreatedBy = "";
			_CreatedDate = DateTime.Now;
			_ModifiedBy = "";
			_ModifiedDate = DateTime.Now;
		}
		public MaterialReqInfo(
		String DTB,
		String RequestNo,
		DateTime RequestDate,
		String ReqFrom,
		String ReqTo,
		String IssueTo,
		String BudgetCode,
		String GLAccount,
		String ShippedBy,
		String ApprovedBy,
		String CreatedBy,
		DateTime CreatedDate,
		String ModifiedBy,
		DateTime ModifiedDate
		)
		{
			_DTB = DTB;
			_RequestNo = RequestNo;
			_RequestDate = RequestDate;
			_ReqFrom = ReqFrom;
			_ReqTo = ReqTo;
			_IssueTo = IssueTo;
			_BudgetCode = BudgetCode;
			_GLAccount = GLAccount;
			_ShippedBy = ShippedBy;
			_ApprovedBy = ApprovedBy;
			_CreatedBy = CreatedBy;
			_CreatedDate = CreatedDate;
			_ModifiedBy = ModifiedBy;
			_ModifiedDate = ModifiedDate;
		}
		public MaterialReqInfo(DataRow dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_RequestNo = dr[Field.RequestNo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.RequestNo.ToString()]);
				_RequestDate = dr[Field.RequestDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.RequestDate.ToString()]);
				_ReqFrom = dr[Field.ReqFrom.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ReqFrom.ToString()]);
				_ReqTo = dr[Field.ReqTo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ReqTo.ToString()]);
				_IssueTo = dr[Field.IssueTo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.IssueTo.ToString()]);
				_BudgetCode = dr[Field.BudgetCode.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.BudgetCode.ToString()]);
				_GLAccount = dr[Field.GLAccount.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.GLAccount.ToString()]);
				_ShippedBy = dr[Field.ShippedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ShippedBy.ToString()]);
				_ApprovedBy = dr[Field.ApprovedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ApprovedBy.ToString()]);
				_CreatedBy = dr[Field.CreatedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CreatedBy.ToString()]);
				_CreatedDate = dr[Field.CreatedDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.CreatedDate.ToString()]);
				_ModifiedBy = dr[Field.ModifiedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ModifiedBy.ToString()]);
				_ModifiedDate = dr[Field.ModifiedDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.ModifiedDate.ToString()]);
			}
		}
		public MaterialReqInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_RequestNo = dr[Field.RequestNo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.RequestNo.ToString()]);
				_RequestDate = dr[Field.RequestDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.RequestDate.ToString()]);
				_ReqFrom = dr[Field.ReqFrom.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ReqFrom.ToString()]);
				_ReqTo = dr[Field.ReqTo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ReqTo.ToString()]);
				_IssueTo = dr[Field.IssueTo.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.IssueTo.ToString()]);
				_BudgetCode = dr[Field.BudgetCode.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.BudgetCode.ToString()]);
				_GLAccount = dr[Field.GLAccount.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.GLAccount.ToString()]);
				_ShippedBy = dr[Field.ShippedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ShippedBy.ToString()]);
				_ApprovedBy = dr[Field.ApprovedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ApprovedBy.ToString()]);
				_CreatedBy = dr[Field.CreatedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CreatedBy.ToString()]);
				_CreatedDate = dr[Field.CreatedDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.CreatedDate.ToString()]);
				_ModifiedBy = dr[Field.ModifiedBy.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.ModifiedBy.ToString()]);
				_ModifiedDate = dr[Field.ModifiedDate.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.ModifiedDate.ToString()]);
			}
		}
		public MaterialReqInfo(MaterialReqInfo objEntr)
		{			
			_DTB = objEntr.DTB;			
			_RequestNo = objEntr.RequestNo;			
			_RequestDate = objEntr.RequestDate;			
			_ReqFrom = objEntr.ReqFrom;			
			_ReqTo = objEntr.ReqTo;			
			_IssueTo = objEntr.IssueTo;			
			_BudgetCode = objEntr.BudgetCode;			
			_GLAccount = objEntr.GLAccount;			
			_ShippedBy = objEntr.ShippedBy;			
			_ApprovedBy = objEntr.ApprovedBy;			
			_CreatedBy = objEntr.CreatedBy;			
			_CreatedDate = objEntr.CreatedDate;			
			_ModifiedBy = objEntr.ModifiedBy;			
			_ModifiedDate = objEntr.ModifiedDate;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("MaterialReq");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.DTB.ToString(), typeof(String)),
				new DataColumn(Field.RequestNo.ToString(), typeof(String)),
				new DataColumn(Field.RequestDate.ToString(), typeof(DateTime)),
				new DataColumn(Field.ReqFrom.ToString(), typeof(String)),
				new DataColumn(Field.ReqTo.ToString(), typeof(String)),
				new DataColumn(Field.IssueTo.ToString(), typeof(String)),
				new DataColumn(Field.BudgetCode.ToString(), typeof(String)),
				new DataColumn(Field.GLAccount.ToString(), typeof(String)),
				new DataColumn(Field.ShippedBy.ToString(), typeof(String)),
				new DataColumn(Field.ApprovedBy.ToString(), typeof(String)),
				new DataColumn(Field.CreatedBy.ToString(), typeof(String)),
				new DataColumn(Field.CreatedDate.ToString(), typeof(DateTime)),
				new DataColumn(Field.ModifiedBy.ToString(), typeof(String)),
				new DataColumn(Field.ModifiedDate.ToString(), typeof(DateTime))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.DTB.ToString()] = _DTB;
			row[Field.RequestNo.ToString()] = _RequestNo;
			row[Field.RequestDate.ToString()] = _RequestDate;
			row[Field.ReqFrom.ToString()] = _ReqFrom;
			row[Field.ReqTo.ToString()] = _ReqTo;
			row[Field.IssueTo.ToString()] = _IssueTo;
			row[Field.BudgetCode.ToString()] = _BudgetCode;
			row[Field.GLAccount.ToString()] = _GLAccount;
			row[Field.ShippedBy.ToString()] = _ShippedBy;
			row[Field.ApprovedBy.ToString()] = _ApprovedBy;
			row[Field.CreatedBy.ToString()] = _CreatedBy;
			row[Field.CreatedDate.ToString()] = _CreatedDate;
			row[Field.ModifiedBy.ToString()] = _ModifiedBy;
			row[Field.ModifiedDate.ToString()] = _ModifiedDate;
			return row;
		}
        #endregion InitTable
    }
}
